<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class main extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		
		
		$this->load->helper('cookie');
		
		//url untuk nama folder
		$this->appurl = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
		$this->appurl .= "://".$_SERVER['HTTP_HOST'];
		$this->appurl .= '/realisasi2s/';
		
		//url untuk nama modul
		$this->murl = '';
	}
	
	public function index(){
		//Mengambil cookie dari hasil setcookie aplikasi utama
		$sesssid = $this->input->cookie('sesssid',TRUE);
		$sesskuid = $this->input->cookie('sesskuid',TRUE);
		
		//Cek apabila cookie sudah di set, load view main
		if(($sesssid!='') && ($sesskuid!='')){
			$data['cookies'] = array(
				'sesssid' => $sesssid,
				'sesskuid' => $sesskuid,
			);
			$data['appurl'] = $this->appurl;
			if($this->murl!=''){$data['modul'] = $this->murl;}
			$this->load->view('main_view',$data);
		}
		//Jika cookie belum di set/tidak ada maka redirect ke halaman login awal
		else{
			header("Location: ".$this->appurl."login.php");
		}
	}
	
	public function modul($mname){
		$this->murl = $mname;
		$this->index();
	}
	
	/* public function dashboard(){
		$data['mhsCount'] =  $this->mdl_mahasiswa->getDataCount();
		$data['mhsActCount'] =  $this->mdl_mahasiswa->getDataCount('ma');
		$data['dsnCount'] =  $this->mdl_dosen->getDataCount();
		
		$data['lblDiagram'] = array("2009","2010","2011","2012","2013","2014","2015");
		$data['dataDiagram'] = $this->mdl_mahasiswa->getDataChart($data['lblDiagram']);
		
		$this->load->view('dashboard',$data);
	} */
	
}